<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送关系设置</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系设置</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系设置</a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
              <div class="input">
                     <div class="textalign1">通用名：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" id="drugName" id="drugName" placeholder="通用名/<spring:message code="message.listForm.pinYinMa"/>"  maxlength="256" />
                    </div>
                    
                    <!-- <div class="textalign1">项目名称：</div>
                    <div class="boxinput">
						<input type="text" class="textinput" id="projId" name="projId" placeholder="项目名称" />
                    </div>
              		 -->
              		
                   <div class="textalign1" >
                        <button   id="selectSee" type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查&nbsp;询</button>
                    </div>
               </div>
			</div>
		</div>
<div style="margin-top: 5px;"></div>
	<table class="jqgrid" id="gridlist"></table>
<div style="margin-top: 10px;"></div>

<div id="prowed2"></div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
$(document).ready(function (){
	//绑定回车   id="selectSee"
	$('#drugName,#drugCode,#projId').bind('keydown', function(event) {
	    if (event.keyCode == "13") {
	        $('#selectSee').click();
	    }
	}); 
	$("#drugName").focus();//加载页面光标在第一个查询框内
	
	
	jQuery("#gridlist").jqGrid({
		url: "${ctx}/baseGoods/getProDelDrugDataList.html",
	    mtype: "POST",
		datatype: "json",
		autowidth: true,
		//shrinkToFit: false,
	   	colNames:['操作',"采购价",'projId','商品编码','所属项目','药品编码','通用名','剂型','规格','转换系数','单位','材质'],
	   	colModel:[
			{name:'oper',index:'n19',width:100, align:"center",sortable: false,
					formatter : function(val, opts, rowdata) {
			    	return "<a href='${ctx}/baseGoods/toBaseGoodsDelByArea.html?goodsCode="+rowdata.goodsCode+"&projID="+rowdata.projId+"&goodsArea="+rowdata.goodsArea+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -140px -60px' class='opIcon' title='按区域设置配送企业'></a><a href='${ctx}/baseGoods/toSetDelByComp.html?goodsCode="+rowdata.goodsCode+"&projID="+rowdata.projId+"&goodsArea="+rowdata.goodsArea+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -120px -60px' class='opIcon' title='按企业设置配送区域'></a>";
			    }	
			},
            {name:'proPriceLimit',index:'proPriceLimit',width:80,align:"right", sortable: false,
                formatter:function(cellvalue, options, row){ 
                    return formatAmount(cellvalue, options, row);
                }   
            },
	   		{name:'projId',index:'goodsCode',hidden:true,width:130,align:"center",sortable: false},
	   		{name:'goodsCode',index:'goodsCode',hidden:true,key:true,width:100,align:"center", sortable: false},//商品编码
	   		{name:'projName',index:'projectName',width:180,sortable: false,hidden:true},
	   		{name:'drugCode', width: 130 , align:"center",hidden:true,sortable: false},
	   		{name:'qualityspecName',index:'qualityspecName',width:240, align:"left", sortable: false/*,
				 formatter:function(val, opts, row) {
					  return "<a href=\"javascript:void(0);\" onclick=\"showDrugInfo('"+row.drugCode+"', '"+val+"')\">"+val+"</a>"
					 }*/},
	   		{name:'formName',index:'formName',width:140, align:"center",sortable: false},
	   		{name:'specName',index:'specName',width:150, align:"left",sortable: false},
	   		{name:'factor',index:'factor',width:80,align:"center", sortable: false},
	   		{name:'unitName',index:'unit',width:60,align:"center", sorttype:false,sortable: false},
	   		{name:'materialName',index:'drugSource',width:90,align:"center", sortable: false,hidden:true}
	   	
	   	],
		gridComplete: function(){
			var ids = jQuery("#gridlist").jqGrid('getDataIDs');
			for(var i=0;i < ids.length;i++){
				var cl = ids[i];
				if (i % 2 == 0) {
				    ae = "&nbsp;&nbsp;<a href='javascript:hosDel("+cl+");' >禁用</a>&nbsp;&nbsp;";
				} else {
					ae = "&nbsp;&nbsp;<a href='javascript:hosDel("+cl+");' >启用</a>&nbsp;&nbsp;";
				}
				jQuery("#gridlist").jqGrid('setRowData',ids[i],{act:ae});
			}	
		},
		 rowNum: 20,
	     rowList: [10, 20, 50, 100],
	     rownumbers: true,
	     pager: "#prowed2",
	     viewrecords: true,
	     caption: "配送关系设置列表",
	     editurl:"proPlanItemListHis.jsp",
	     gridComplete: function(){
	          	//序号列宽度自适应（参数为jqgridID）
	             autoRNWidth("gridlist");
	          	//数据只有一条时默认选中（参数为jqgridID）
	              selectByOneData("gridlist");
			     },
	     jsonReader: {
	         repeatitems: false,
	         id: "ids"
	     }
	   	
	});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGridHeight", create());
	
	
	$("#projId").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getProjByProdCompId.html", data: { ID: '' },defaultselect:'${form.patternType}',  defaultText: "<option value=''>请选择</option>",
    });
})

function gridSerch(){
	var goodsCode = $.trim($("#goodsCode").val());
	var drugCode = $.trim($("#drugCode").val());
	var drugName = $.trim($("#drugName").val());
	var projId = $.trim($("#projId").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"goodsCode":goodsCode,
        		"drugCode":drugCode,
        		"drugName":drugName,
        		"projId":projId}
    }).trigger("reloadGrid"); //重新载入  
}

</script>
</body>
</html>